package com.atguigu.srb.core.controller.api;


import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.entity.IntegralGrade;
import com.atguigu.srb.core.service.IntegralGradeService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 积分等级表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-06-30
 */
@RestController
@RequestMapping("/api/core/integralGrade")
@Api(tags = "会员积分管理模块")
public class ApiIntegralGradeController {
    //查询所有
    @Resource
    private IntegralGradeService IGService;
    //查询用户的借款的额度是多少
    @ApiOperation("查询用户的可借款额度")
    @GetMapping("/auth/amount")
    public R getAmount(@RequestHeader("token")String token){
        BigDecimal amount = IGService.getAmount(token);
        return R.ok().data("amount",amount);
    }
    //查询所有,带分页功能的
    @ApiOperation("分页查询积分等级")
    @GetMapping("/{pageNum}/{pageSize}")
    public R getPageList(
            @ApiParam(name = "pageNum",value = "当前的页码",required = true)@PathVariable("pageNum") Integer pageNum,
            @ApiParam(name = "pageSize",value = "当前的页面条数",required = true)@PathVariable("pageSize")Integer pageSize
    ){
        //查询分页的信息
        return R.ok().data("pageInfo",IGService.page(new Page(pageNum,pageSize)));
    }

}

